﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ClimateControl.Infrastructure.Extensions;
using ClimateControl.Infrastructure.Service;

namespace ClimateControl.Infrastructure
{
    public class ClimateInfo : IClimateInfo
    {
        private List<Vote> _votes;
        public List<Vote> Votes
        {
            get { return _votes.Where(v => v.Time.IsInTheLast(VoteExpiry).Minutes).ToList(); }
            set { _votes = value; }
        }
        public bool IsAirConOn { get; set; }
        public int Temperature { get; set; }
        public double VoteFrequency { get; set; }
        public int VoteExpiry { get; set; }
        public bool IsBigFanOn { get; set; }
        public int UpdateFrequency { get; set; }

        public ClimateInfo()
        {
            Votes = new List<Vote>();
            IsAirConOn = false;
            IsBigFanOn = false;
            Temperature = 20;
            VoteFrequency = 4;
            VoteExpiry = 20;
            UpdateFrequency = 30;
        }

        public void AddVote(Vote vote)
        {
            _votes.Add(vote);
        }
    }
}
